home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1992 August / info-mac-1992.iso / Applications (app) / Image 1.44 / Macros / Line Plots->Data < prev    next >
Text File  |  1991-06-11  |  2KB  |  111 lines

  1. macro 'Convert Line Plot to Points [C]';
  2. {
  3. Requires a binary image conatining a black plot on a white
  4. background. Select the plot before running this macro. It may be
  5. necessary to increase Max Measurements in Options.
  6. }
  7. var
  8.   left,top,width,height,i:integer;
  9. begin
  10.   SaveState;
  11.   GetRoi(left,top,width,height);
  12.   if width=0 then begin
  13.     PutMessage('Please select the line plot.');
  14.     exit;
  15.   end;
  16.   Duplicate('Particles');
  17.   i:=0;
  18.   SetForegroundColor(0);
  19.   SetLineWidth(1);
  20.   repeat
  21.     MoveTo(i,0);
  22.     LineTo(i,height);
  23.     i:=i+2;
  24.   until i>width;
  25.   RotateRight(true);
  26.   MeasureArea(false);
  27.   MeasureDensity(false);
  28.   MeasureXY(true);
  29.   LabelParticles(false);
  30.   SetParticleSize(1,999999);
  31.   InvertY(false);
  32.   AnalyzeParticles;
  33.   RestoreState;
  34. end;
  35.  
  36.  
  37. macro 'Plot Points [P]';
  38. {
  39. Plots the data points contained in the X and Y results columns. Note
  40. that X and Y are reversed because Analyze Particles scans from top
  41. to bottom, not left to right.
  42. }
  43. var
  44.   xmin,xmax,ymin,ymax,i,xscale,yscale:real;
  45.   width,height,margin,pwidth,pheight:integer;
  46. begin
  47.   SaveState;
  48.   margin:=40;
  49.   width:=500;
  50.   height:=300;
  51.   xmin:=999999;
  52.   xmax:=-999999;
  53.   ymin:=999999;
  54.   ymax:=-999999;
  55.   for i:=1 to rCount do begin
  56.     if rX[i]<xmin then xmin:=rX[i];
  57.     if rX[i]>xmax then xmax:=rX[i];
  58.     if rY[i]<ymin then ymin:=rY[i];
  59.     if rY[i]>ymax then ymax:=rY[i];
  60.   end;
  61.   SetNewSize(width,height);
  62.   MakeNewWindow('Plot');
  63.   pwidth:=width-2*margin;
  64.   pheight:=height-2*margin;
  65.   xscale:=pheight/(xmax-xmin);
  66.   yscale:=pwidth/(ymax-ymin);
  67.   SetForeground(255);
  68.   SetBackground(0); 
  69.   MoveTo(margin,margin);
  70.   for i:=1 to rCount do begin
  71.     LineTo(margin+(rY[i]-ymin)*yscale,margin+(rX[i]-xmin)*xscale);
  72.   end;
  73.   MakeRoi(margin,margin,pwidth+1,pheight+2);
  74.   MoveTo(margin,margin);
  75.   LineTo(margin+pwidth,margin);
  76.   MoveTo(margin,margin);
  77.   LineTo(margin,margin+pheight);
  78.   FlipVertical;
  79.   KillRoi;
  80.   SetFont('Geneva');
  81.   SetFontSize(9);
  82.   SetText('Centered');
  83.   MoveTo(margin+4,margin+pheight+12);
  84.   writeln(ymin:1:2);
  85.   MoveTo(margin+pwidth,margin+pheight+12);
  86.   writeln(ymax:1:2);
  87.   SetText('Right Justified');
  88.   MoveTo(margin-2,margin+pheight-5);
  89.   writeln(xmin:1:2);
  90.   MoveTo(margin-2,margin);
  91.   writeln(xmax:1:2);
  92.   RestoreState;
  93. end;
  94.  
  95.  
  96. macro 'Clear Outside [O]'
  97.  {Outline the line plot with the wand tool and then use this macro to}
  98.  {erase everything else.}
  99. begin
  100.   Copy;
  101.   SelectAll;
  102.   Clear;
  103.   RestoreRoi;
  104.   Paste;
  105.   KillRoi;
  106. end;
  107.  
  108.  
  109.  
  110.  
  111.